<template>
  <h1>表单组件</h1>
  <el-form style="width: 424px;margin: 0 auto" label-width="100px" >
    <el-form-item label="用户名">
      <el-input placeholder="请输入用户名" type="text" v-model="user.name"/>
    </el-form-item>
    <el-form-item label="密码">
      <el-input placeholder="请输入密码" show-password type="password" v-model="user.pwd"/>
    </el-form-item>
    <el-form-item label="性别">
      <el-radio-group v-model="user.gender">
        <el-radio-button label="男" value="1"></el-radio-button>
        <el-radio-button label="女" value="0"></el-radio-button>
      </el-radio-group>
    </el-form-item>
    <el-form-item label="所在地">
      <el-select placeholder="请选择所在地" v-model="user.address">
        <el-option label="北京" value="bj"></el-option>
        <el-option label="上海" value="sh"></el-option>
        <el-option label="广州" value="gz"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="是否管理员">
      <el-switch v-model="user.isAdmin" />
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="submit">提交</el-button>
      <el-button type="danger" @click="reset">重置</el-button>
    </el-form-item>
  </el-form>
</template>
<script setup>
import {ref} from "vue";
const user = ref({
  name:'',
  pwd:'',
  gender:'',
  address:'',
  isAdmin:'false',
});
const submit = ()=>{
  console.log(user.value);
}
const reset = ()=>{
  user.value = {
    name:'',
    pwd:'',
    gender:'',
    address:'',
    isAdmin:'false',
  }
}
</script>
<style scoped>

</style>